package com.jjkj.environmental.environmental.utils.pull

import okhttp3.MediaType
import okhttp3.RequestBody
import okhttp3.ResponseBody
import retrofit2.Converter
import retrofit2.Retrofit
import java.lang.reflect.Type

class PullConverterFactory private constructor() : Converter.Factory() {


    companion object {
        val XML = MediaType.parse("application/xml; charset=utf-8")

        fun create(): PullConverterFactory = PullConverterFactory()
    }

    override fun responseBodyConverter(type: Type, annotations: Array<Annotation>, retrofit: Retrofit): Converter<ResponseBody, *>? {
        return PullResponseConverter(type as Class<*>)
    }

    override fun requestBodyConverter(type: Type, parameterAnnotations: Array<Annotation>, methodAnnotations: Array<Annotation>, retrofit: Retrofit): Converter<*, RequestBody>? {
        return PullRequestConverter(type as Class<*>)
    }
}